Initial commit

This commit is contained in:
alexpete
2021-03-05 11:26:34 -08:00
commit a10351f38d
27091 changed files with 5521199 additions and 0 deletions
@@ -0,0 +1,24 @@
----------------------------------------------------------------------------------------------------
--
-- All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
-- its licensors.
--
-- For complete copyright and license terms please see the LICENSE at the root of this
-- distribution (the "License"). All use of this software is governed by the License,
-- or, if provided, by the license below or the license accompanying this file. Do not
-- remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--
--
----------------------------------------------------------------------------------------------------
CameraSource = {
Editor={
Icon="Camera.bmp",
},
};
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function CameraSource:OnInit()
self:CreateCameraComponent();
self:SetFlags(ENTITY_FLAG_CLIENT_ONLY,0);
end
@@ -0,0 +1,15 @@
----------------------------------------------------------------------------------------------------
--
-- All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
-- its licensors.
--
-- For complete copyright and license terms please see the LICENSE at the root of this
-- distribution (the "License"). All use of this software is governed by the License,
-- or, if provided, by the license below or the license accompanying this file. Do not
-- remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--
--
----------------------------------------------------------------------------------------------------
CameraTarget = {
}
+214
View File
@@ -0,0 +1,214 @@
----------------------------------------------------------------------------------------------------
--
-- All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
-- its licensors.
--
-- For complete copyright and license terms please see the LICENSE at the root of this
-- distribution (the "License"). All use of this software is governed by the License,
-- or, if provided, by the license below or the license accompanying this file. Do not
-- remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--
-- Description: Comment system.
--
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
-- $Id$
-- $DateTime$
-- Description: Comment system.
--
----------------------------------------------------------------------------------------------------
Comment =
{
Properties =
{
Text = "This is a comment",
fSize = 1.2, --[0.0, 100.0 , 0.1, ""]
bHidden = 0,
fMaxDist = 100, --[0.0 ,255.0 , 0.1, ""]
nCharsPerLine = 30, --[1, 255, 1, ""]
bFixed = 0,
clrDiffuse = { x=1,y=0.5,z=0 },
},
Editor={
Model="Editor/Objects/comment.cgf",
Icon="Comment.bmp",
},
hidden = 0,
lines = {},
lineCount = 0,
fMaxDistSquared = 0,
bNoUpdateInGame = 1,
}
-------------------------------------------------------
function Comment:OnLoad(table)
self.hidden = table.hidden;
end
-------------------------------------------------------
function Comment:OnSave(table)
table.hidden = self.hidden;
end
-------------------------------------------------------
function Comment:OnInit()
-- Delete when not in dev-mode.
if (not System.IsDevModeEnable() ) then
self:DeleteThis();
return;
end
self:OnReset();
end
-------------------------------------------------------
function Comment:OnSpawn()
end
-------------------------------------------------------
function Comment:OnPropertyChange()
self:OnReset();
end
-------------------------------------------------------
function Comment:OnReset()
-- Comment is only Active(OnUpdate() will be called) when in Editor or when cl_comment > 0
local cl_comment = System.GetCVar("cl_comment")
if (System.IsEditor() or cl_comment > 0) then
self:SetUpdatePolicy( ENTITY_UPDATE_VISIBLE );
self:Activate(1)
else
self:Activate(0);
end
-- bNoUpdateInGame is checked in OnUpdate() to account for in-editor game mode.
if (cl_comment == 0) then
self.bNoUpdateInGame = 1;
else
self.bNoUpdateInGame = 0;
end
self.fMaxDistSquared = self.Properties.fMaxDist * self.Properties.fMaxDist;
self.hidden = self.Properties.bHidden;
self.lines = {};
-- process the text and line-break it
local maxLength = self.Properties.nCharsPerLine;
local curLength = 0;
local curText = "";
local curLine = 1;
for char in string.gfind(self.Properties.Text, ".") do
if (char == " ") then
-- word finished ... see if we are over the limit
if (curLength > maxLength) then
-- commit line
self.lines[curLine] = curText;
curLine = curLine + 1;
curText = "";
curLength = 0;
-- "consume" the whitespace
char = "";
end
end
if (char ~= "") then
-- append char
curText = curText..char;
curLength = curLength + 1;
end
end
self.lines[curLine] = curText;
self.lineCount = curLine;
self:OnUpdate(0);
end
-------------------------------------------------------
function Comment:OnUpdate(delta)
if (self.hidden ~= 0 or self:IsHidden() or self.Properties.Text =="" or (self.bNoUpdateInGame == 1 and not System.IsEditing())) then
return;
end
-- calculate alpha
local alpha = 0;
local factor = 0;
if (self.fMaxDistSquared>0) then
local mypos = g_Vectors.temp_v1;
self:GetWorldPos(mypos);
SubVectors(mypos, mypos, System.GetViewCameraPos());
local distSquared = LengthSqVector(mypos);
factor = distSquared;
if (self.Properties.fMaxDist >= 255.0) then
alpha = 1.0;
elseif (distSquared<self.fMaxDistSquared) then
alpha = distSquared/self.fMaxDistSquared;
alpha = 1.0 - alpha*alpha;
end
end
-- draw text
local increment = System.GetViewCameraUpDir();
if (alpha>0.001) then
local pos = self:GetWorldPos( g_Vectors.temp_v1 );
factor = math.sqrt(factor);
factor = (self.Properties.fSize/60) * factor * System.GetViewCameraFov();
local incrementAll = g_Vectors.temp_v4;
FastScaleVector(increment, increment, factor);
FastScaleVector(incrementAll, increment, (self.lineCount / 2 + 1));
-- start all the way at the top
FastSumVectors(pos, pos, incrementAll);
local textColor = { x=0, y=1, z=0 }; -- default color is for (bFixed == 1)
if (self.Properties.bFixed ~= 1) then
textColor = {x=self.Properties.clrDiffuse.x, y=self.Properties.clrDiffuse.y, z=self.Properties.clrDiffuse.z};
end
for i,val in ipairs(self.lines) do
System.DrawLabel( pos, self.Properties.fSize, val, textColor.x, textColor.y, textColor.z, alpha );
-- decrement the increment
FastDifferenceVectors(pos, pos, increment);
end
end
end
-------------------------------------------------------
function Comment:Event_UnHide(sender)
BroadcastEvent(self, "UnHide");
self.hidden = 0;
end
-------------------------------------------------------
function Comment:Event_Hide(sender)
BroadcastEvent(self, "Hide");
self.hidden = 1;
end
-------------------------------------------------------
Comment.FlowEvents =
{
Inputs =
{
Hide = { Comment.Event_Hide, "bool" },
UnHide = { Comment.Event_UnHide, "bool" },
},
Outputs =
{
Hide = "bool",
UnHide = "bool",
},
}
@@ -0,0 +1,128 @@
----------------------------------------------------------------------------------------------------
--
-- All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
-- its licensors.
--
-- For complete copyright and license terms please see the LICENSE at the root of this
-- distribution (the "License"). All use of this software is governed by the License,
-- or, if provided, by the license below or the license accompanying this file. Do not
-- remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--
--
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------
--
-- Description : Procedural object entity
--
-- Created by Marco C. May 2013
--
----------------------------------------------------------------------------
ProceduralObject = {
type = "ProceduralObject",
Properties = {
filePrefabLibrary= "",
ObjectVariation={
sPrefabVariation = "",
},
nMaxSpawn = 0,
},
-- editor information
Editor = {
Icon = "proceduralobject.bmp",
ShowBounds = 1,
},
PrefabSourceName = "",
--Client = {},
--Server = {},
}
function ProceduralObject:OnInit()
--System.Log( "OnInit proc object" );
self:OnReset();
end
function ProceduralObject:OnPropertyChange()
--System.Log( "OnPropertyChange" );
self:OnReset();
end
function ProceduralObject:OnDestroy( sender )
PrefabManager.Delete(self.id);
end
function ProceduralObject:OnMove()
--System.Log( "OnMove proc object" );
PrefabManager.Move(self.id);
end
function ProceduralObject:OnSpawn()
if (CryAction.IsClient()) then
--System.Log( "CLIENT" );
self:SetFlags(ENTITY_FLAG_CLIENT_ONLY,0);
end
if (CryAction.IsServer()) then
--System.Log( "SERVER" );
self:SetFlags(ENTITY_FLAG_SERVER_ONLY,0);
end
end
function ProceduralObject:Spawn(seed)
--System.Log( "Spawning proc object" );
--System.Log( "PrefabName="..self.PrefabSourceName );
PrefabManager.Delete(self.id);
local props=self.Properties;
if(not EmptyString(props.filePrefabLibrary)) then
--System.Log( "Opening file:"..props.filePrefabLibrary);
PrefabManager.LoadLibrary(props.filePrefabLibrary);
if(not EmptyString(props.ObjectVariation.sPrefabVariation)) then
PrefabManager.Spawn(self.id,props.filePrefabLibrary,props.ObjectVariation.sPrefabVariation,seed,props.nMaxSpawn);
end
end
--System.Log( "PrefabName="..self.PrefabSourceName );
end
function ProceduralObject:OnHidden()
PrefabManager.Hide(self.id,true);
end
function ProceduralObject:OnUnHidden()
PrefabManager.Hide(self.id,false);
end
function ProceduralObject:OnReset( sender )
--System.Log( "OnReset" );
if (System.IsEditor()) then
-- change prefabs only if we are editing (and the user pressed reload script),
-- do not change every time we go in and out of game mode...
-- unless we are in game mode generation
local clientgamemode=0; --System.GetCVar("g_GameModeGenerate");
if (System.IsEditing() or clientgamemode==1) then
PrefabManager.Delete(self.id);
self:Spawn(0);
end
else
PrefabManager.Delete(self.id);
end
--System.Log( "OnReset done" );
end
@@ -0,0 +1,208 @@
----------------------------------------------------------------------------------------------------
--
-- All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
-- its licensors.
--
-- For complete copyright and license terms please see the LICENSE at the root of this
-- distribution (the "License"). All use of this software is governed by the License,
-- or, if provided, by the license below or the license accompanying this file. Do not
-- remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--
--
----------------------------------------------------------------------------------------------------
RigidBody = {
type = "RigidBody",
MapVisMask = 0,
Properties = {
soclasses_SmartObjectClass = "",
bAutoGenAIHidePts = 0,
objModel = "Objects/box.cgf",
Density = 5000,
Mass = 1,
bResting = 1, -- If rigid body is originally in resting state.
bVisible = 1, -- If rigid body is originally visible.
bRigidBodyActive = 1, -- If rigid body is originally created OR will be created only on OnActivate.
bActivateOnRocketDamage = 0, -- Activate when a rocket hit the entity.
Impulse = {X=0,Y=0,Z=0}, -- Impulse to apply at event.
max_time_step = 0.01,
sleep_speed = 0.04,
damping = 0,
water_damping = 1.5,
water_resistance = 0,
},
temp_vec={x=0,y=0,z=0},
PhysParams = { mass=0,density=0 },
updateTime = 500,
gravityUpdate = 0,
Editor={
Icon = "physicsobject.bmp",
IconOnTop=1,
},
}
-------------------------------------------------------
function RigidBody:OnInit()
self.ModelName = "";
self.Mass = 0;
self:OnReset();
-- System.Log( "here1" );
end
-------------------------------------------------------
function RigidBody:OnReset()
--self:NetPresent(nil);
if (self.ModelName ~= self.Properties.objModel or self.Mass ~= self.Properties.Mass) then
self.Mass = self.Properties.Mass;
self.ModelName = self.Properties.objModel;
self:LoadObject( 0,self.ModelName );
end
local Properties = self.Properties;
if (Properties.bVisible == 0) then
self:DrawSlot( 0,0 );
else
self:DrawSlot( 0,1 );
end
local physType;
if (self.Properties.bRigidBodyActive == 1) then
physType = PE_RIGID;
self.PhysParams.density = Properties.Density;
self.PhysParams.mass = Properties.Mass;
else
physType = PE_STATIC;
end
self:Physicalize( 0,physType,self.PhysParams );
self:SetPhysicParams(PHYSICPARAM_SIMULATION, self.Properties );
self:SetPhysicParams(PHYSICPARAM_BUOYANCY, self.Properties );
if (self.Properties.bResting == 0) then
self:AwakePhysics(1);
else
self:AwakePhysics(0);
end
-- Mark AI hideable flag.
if (self.Properties.bAutoGenAIHidePts == 1) then
self:SetFlags(ENTITY_FLAG_AI_HIDEABLE, 0); -- set
else
self:SetFlags(ENTITY_FLAG_AI_HIDEABLE, 2); -- remove
end
end
-------------------------------------------------------
function RigidBody:OnPropertyChange()
self:OnReset();
end
-------------------------------------------------------
function RigidBody:OnContact( player )
self:Event_OnTouch( player );
end
-------------------------------------------------------
function RigidBody:OnDamage( hit )
--System.LogToConsole( "On Damage" );
if( hit.ipart ) then
self:AddImpulse( hit.ipart, hit.pos, hit.dir, hit.impact_force_mul );
-- else
-- self:AddImpulse( -1, hit.pos, hit.dir, hit.impact_force_mul );
end
if(self.Properties.bActivateOnRocketDamage)then
if(hit.explosion)then
self:AwakePhysics(1);
end
end
end
-------------------------------------------------------
function RigidBody:OnShutDown()
end
-------------------------------------------------------
function RigidBody:OnTimer()
-- System.Log("RigidBody OnTimer");
-- self:SetTimer( 0,1000 );
end
function RigidBody:OnUpdate()
--FIXME: all this timing stuff will be replaced by OnTimer once it will work again
self.gravityUpdate = self.gravityUpdate + _frametime;
if (self.gravityUpdate < 0.5) then
return;
end
self.gravityUpdate = 0.0;
EntityUpdateGravity(self);
end
-------------------------------------------------------
-- Input events
-------------------------------------------------------
function RigidBody:Event_AddImpulse(sender)
self.temp_vec.x=self.Properties.Impulse.X;
self.temp_vec.y=self.Properties.Impulse.Y;
self.temp_vec.z=self.Properties.Impulse.Z;
self:AddImpulse(0,nil,self.temp_vec,1);
end
-------------------------------------------------------
function RigidBody:Event_Activate(sender)
--create rigid body
self:CreateRigidBody( self.Properties.Density,self.Properties.Mass,0 );
self:Activate(1);
self:AwakePhysics(1);
end
-------------------------------------------------------
function RigidBody:Event_Show(sender)
self:DrawSlot( 0,1 );
end
-------------------------------------------------------
function RigidBody:Event_Hide(sender)
self:DrawSlot( 0,0 );
end
-------------------------------------------------------
-- Output events
-------------------------------------------------------
function RigidBody:Event_OnTouch(sender)
BroadcastEvent( self,"OnTouch" );
end
RigidBody.FlowEvents =
{
Inputs =
{
Activate = { RigidBody.Event_Activate, "bool" },
AddImpulse = { RigidBody.Event_AddImpulse, "bool" },
Hide = { RigidBody.Event_Hide, "bool" },
Show = { RigidBody.Event_Show, "bool" },
OnTouch = { RigidBody.Event_OnTouch, "bool" },
},
Outputs =
{
Activate = "bool",
AddImpulse = "bool",
Hide = "bool",
Show = "bool",
OnTouch = "bool",
},
}