/// <summary> /// Constructor. /// </summary> /// <param name="netManager">The network manager owning this player.</param> /// <param name="netWorld">Network world owning this player.</param> /// <param name="steamId">The steam id of the player.</param> public NetLocalPlayer( NetManager netManager, NetWorld netWorld, Steamworks.CSteamID steamId) : base(netManager, netWorld, steamId) { Instance = this; steamID = steamId; GameDoorsManager.Instance.onDoorsOpen = (GameObject door) => { Messages.OpenDoorsMessage msg = new Messages.OpenDoorsMessage(); msg.position = Utils.GameVec3ToNet(door.transform.position); msg.open = true; netManager.BroadcastMessage(msg, Steamworks.EP2PSend.k_EP2PSendReliable); }; GameDoorsManager.Instance.onDoorsClose = (GameObject door) => { Messages.OpenDoorsMessage msg = new Messages.OpenDoorsMessage(); msg.position = Utils.GameVec3ToNet(door.transform.position); msg.open = false; netManager.BroadcastMessage(msg, Steamworks.EP2PSend.k_EP2PSendReliable); }; LightSwitchManager.Instance.onLightSwitchUsed = (GameObject lswitch, bool turnedOn) => { Messages.LightSwitchMessage msg = new Messages.LightSwitchMessage(); msg.pos = Utils.GameVec3ToNet(lswitch.transform.position); msg.toggle = turnedOn; netManager.BroadcastMessage(msg, Steamworks.EP2PSend.k_EP2PSendReliable); }; if (animManager == null) { animManager = new PlayerAnimManager(); } }
/// <summary> /// Spawns character object in world. /// </summary> public void Spawn() { GameObject loadedModel = Client.LoadAsset <GameObject>(CHARACTER_PREFAB_NAME); characterGameObject = (GameObject)GameObject.Instantiate((GameObject)loadedModel, interpolator.CurrentPosition, interpolator.CurrentRotation); // If character will disappear we uncomment this // GameObject.DontDestroyOnLoad(go); //Getting the Animation component of the model, and setting the priority layers of each animation if (AnimManager == null) { AnimManager = new PlayerAnimManager(); Logger.Debug("AnimManager: JUST CREATED MORE!"); } else { Logger.Debug("AnimManager: We had already (from NetLocal) our animManager"); } AnimManager.SetupAnimations(characterGameObject); if (pickedUpObjectNetId != NetPickupable.INVALID_ID) { UpdatePickedUpObject(true, false); } if (currentVehicle != null) { SitInCurrentVehicle(); } }
/// <summary> /// Constructor. /// </summary> /// <param name="netManager">The network manager owning this player.</param> /// <param name="netWorld">Network world owning this player.</param> /// <param name="steamId">The steam id of the player.</param> public NetLocalPlayer(NetManager netManager, NetWorld netWorld, Steamworks.CSteamID steamId) : base(netManager, netWorld, steamId) { GameDoorsManager.Instance.onDoorsOpen = (GameObject door) => { Messages.OpenDoorsMessage msg = new Messages.OpenDoorsMessage(); msg.position = Utils.GameVec3ToNet(door.transform.position); msg.open = true; netManager.BroadcastMessage(msg, Steamworks.EP2PSend.k_EP2PSendReliable); }; GameDoorsManager.Instance.onDoorsClose = (GameObject door) => { Messages.OpenDoorsMessage msg = new Messages.OpenDoorsMessage(); msg.position = Utils.GameVec3ToNet(door.transform.position); msg.open = false; netManager.BroadcastMessage(msg, Steamworks.EP2PSend.k_EP2PSendReliable); }; GameCallbacks.onObjectPickup = (GameObject gameObj) => { Messages.PickupObjectMessage msg = new Messages.PickupObjectMessage(); msg.netId = netWorld.GetPickupableNetId(gameObj); Client.Assert(msg.netId != NetPickupable.INVALID_ID, "Tried to pickup not network pickupable."); netManager.BroadcastMessage(msg, Steamworks.EP2PSend.k_EP2PSendReliable); }; GameCallbacks.onObjectRelease = (bool drop) => { Messages.ReleaseObjectMessage msg = new Messages.ReleaseObjectMessage(); msg.drop = drop; netManager.BroadcastMessage(msg, Steamworks.EP2PSend.k_EP2PSendReliable); }; BeerCaseManager.Instance.onBottleConsumed = (GameObject bcase) => { Messages.RemoveBottleMessage msg = new Messages.RemoveBottleMessage(); msg.netId = netWorld.GetPickupableNetId(bcase); Client.Assert(msg.netId != NetPickupable.INVALID_ID, "Tried to drink from not network beercase."); netManager.BroadcastMessage(msg, Steamworks.EP2PSend.k_EP2PSendReliable); }; LightSwitchManager.Instance.onLightSwitchUsed = (GameObject lswitch, bool turnedOn) => { Messages.LightSwitchMessage msg = new Messages.LightSwitchMessage(); msg.pos = Utils.GameVec3ToNet(lswitch.transform.position); msg.toggle = turnedOn; netManager.BroadcastMessage(msg, Steamworks.EP2PSend.k_EP2PSendReliable); }; if (animManager == null) { animManager = new PlayerAnimManager(); } }
public PlayerAnimManager() { Instance = this; }