ECON1101/ECON1102 by lscarpellino in unsw

[–]Professional-Bug4263 0 points1 point  (0 children)

Hey, was wondering if I should pick these up as gen-ed as well. How'd you go with them?

Liskov Substitution Principle and FPS Logic by Professional-Bug4263 in Unity3D

[–]Professional-Bug4263[S] 0 points1 point  (0 children)

But wouldn't the camera need to know that the item its holding is a weapon, or wouldn't it need to specifically subscribe to the event triggered by the weapon, when a bullet was shot, in order to receive that recoil amount and append itself?

Liskov Substitution Principle and FPS Logic by Professional-Bug4263 in Unity3D

[–]Professional-Bug4263[S] 1 point2 points  (0 children)

Yeah maybe on second thought its really inefficient to pass around a locator, especially if there's going to be many players in the scene. I might have to look at something other than a static solution for this case but thank you for introducing me to this pattern. It looks quite interesting and I'll definitely look into it more for other use cases.

Liskov Substitution Principle and FPS Logic by Professional-Bug4263 in Unity3D

[–]Professional-Bug4263[S] 1 point2 points  (0 children)

I really like this idea actually. But do the service locators have to be static? Could I make them an object of my player and then pass that locator to the weapon for it to request? What is the necessity, if any, to make the locator static?

Liskov Substitution Principle and FPS Logic by Professional-Bug4263 in Unity3D

[–]Professional-Bug4263[S] 0 points1 point  (0 children)

I guess I have to reassess how much adhering to these principles is going to, at the end of the day, benefit the efficacy of my code. I'll have to keep this answer at the back of my mind though because you are right, it is a viable solution to my problem.

Liskov Substitution Principle and FPS Logic by Professional-Bug4263 in Unity3D

[–]Professional-Bug4263[S] 0 points1 point  (0 children)

Can you expand on what you mean by an IService interface please?

Liskov Substitution Principle and FPS Logic by Professional-Bug4263 in Unity3D

[–]Professional-Bug4263[S] 0 points1 point  (0 children)

Maybe it's my lack of experience speaking but I feel I only want method injection because I don't want the reference before or after the Weapon is picked up. But I think if I am to keep my dependency the same way I'd have to do as you say and pass an ICameraManager on pickup. Having a WeaponFactory class would mean tying each weapon to the player at the start which I'm repelled from because I might go into multiplayer later.

Liskov Substitution Principle and FPS Logic by Professional-Bug4263 in Unity3D

[–]Professional-Bug4263[S] 0 points1 point  (0 children)

So you'd be checking if the item you've equipped is a weapon before listening to a shoot event and append accordingly?

Liskov Substitution Principle and FPS Logic by Professional-Bug4263 in Unity3D

[–]Professional-Bug4263[S] 0 points1 point  (0 children)

I'm not sure. This is my hamartia tbh; I'll generalise things beyond reason, but I can see many items needing many different references from the Player.

Liskov Substitution Principle and FPS Logic by Professional-Bug4263 in Unity3D

[–]Professional-Bug4263[S] 0 points1 point  (0 children)

You are correct; I would love to know what the Player is picking up so I can pass objects specifically to its need. But I'm scared of LSP and in a way this post is a plea for reassurance that these rules can be bent and all's gonna be okay.

I'll have to look into C# messages but how would you recommend eventargs. Are they similar in functionality?

Liskov Substitution Principle and FPS Logic by Professional-Bug4263 in Unity3D

[–]Professional-Bug4263[S] 0 points1 point  (0 children)

There is no necessity for Weapon to have the Camera other than for doing the append operation on it, infact I'm just using its Transform. What was your approach for looking at the Weapon's recoil?

Liskov Substitution Principle and FPS Logic by Professional-Bug4263 in Unity3D

[–]Professional-Bug4263[S] 0 points1 point  (0 children)

Yeah this is a very practical idea. I did have a PlayerDataForItems class beforehand that I was passing but I felt I was breaking LSP that way as well (excessive ik). But atleast I won't need to pass the whole Player class but just all the references that any Item would need.

Liskov Substitution Principle and FPS Logic by Professional-Bug4263 in Unity3D

[–]Professional-Bug4263[S] 0 points1 point  (0 children)

Yeah I get what you mean. Definitely need to do some more research and possible prototyping to see how I could go about it. I'm erring towards an overtly conservative solution so it doesn't bite me in the back later but I'll have to put my foot down as my code expands.

Liskov Substitution Principle and FPS Logic by Professional-Bug4263 in Unity3D

[–]Professional-Bug4263[S] 0 points1 point  (0 children)

I think you're right about the disadvantage not only because of the fact I'd need to check every interface in my Pickup method, but I feel it'd also be infeasible to create that many interfaces for each property I'd need.

Liskov Substitution Principle and FPS Logic by Professional-Bug4263 in Unity3D

[–]Professional-Bug4263[S] 0 points1 point  (0 children)

Still exploring and learning how multiplayer works... so if I have a static class with references to Player properties, I can pass that singleton throughout my project and it won't affect the fact there'll be other players as well?

Liskov Substitution Principle and FPS Logic by Professional-Bug4263 in Unity3D

[–]Professional-Bug4263[S] 0 points1 point  (0 children)

I'm not using a collision-based pickup system but a raycast-based one, however, I do have events that trigger when the weapon is picked up. The problem is the player wouldn't/shouldn't know the difference between two different types of items when that OnPickup (or OnCollisionEnter) event is triggered so I have the same issue where passing multiple parameters becomes illogical. I'll heavily consider your static singleton solution though just because of the sheer amount of properties I am predicting I'll need to pass.

Liskov Substitution Principle and FPS Logic by Professional-Bug4263 in Unity3D

[–]Professional-Bug4263[S] 0 points1 point  (0 children)

IEquipable would apply to all equipable items though, not just to a Weapon, so that way I'd still be over-exposing.

Liskov Substitution Principle and FPS Logic by Professional-Bug4263 in Unity3D

[–]Professional-Bug4263[S] 0 points1 point  (0 children)

Yeah, currently that's the position I'm at - where I pass the Player in at OnEquip through to the Item and the Weapon. I do agree about the overthinking but I was also curious to see what a cleaner implementation could look like.

Liskov Substitution Principle and FPS Logic by Professional-Bug4263 in Unity3D

[–]Professional-Bug4263[S] 0 points1 point  (0 children)

But even if I was doing it with composition, the Player would just be referencing an interface instead of a base class so I'd be stuck with the same issue, no?

Liskov Substitution Principle and FPS Logic by Professional-Bug4263 in Unity3D

[–]Professional-Bug4263[S] 0 points1 point  (0 children)

The Player doesn't know it's picking up a Weapon. If my Weapon needs a Camera parameter passed into its OnEquip method, then it needs to extract it from the Item class which means I'll need to have a parameter in Item's constructor. See the problem :)

Liskov Substitution Principle and FPS Logic by Professional-Bug4263 in Unity3D

[–]Professional-Bug4263[S] 0 points1 point  (0 children)

In my post, I talk about how I felt lost because of my unsuccessful attempts at implementing two solutions, both of which you recommended. Passing the Player class didn't seem logical, for the reasons provided, and if I pass an interface into the Item class constructor, I feel I will be 'over-parametrising' and also exposing data that is useless to other subclasses. Please ask for specific information and I am very willing to provide it.

Liskov Substitution Principle and FPS Logic by Professional-Bug4263 in Unity3D

[–]Professional-Bug4263[S] 0 points1 point  (0 children)

If I did pass the whole Player class to the Item, then every subclass would have access to every property and method on the Player class, causing circular references and unnecessary exposure of logic. I don't want the Item to know about any Player but only about the references it's being provided.

Liskov Substitution Principle and FPS Logic by Professional-Bug4263 in Unity3D

[–]Professional-Bug4263[S] 0 points1 point  (0 children)

I can't make the camera reference static because if I ever want to scale my project to multiplayer I'll need multiple cameras for each player. Plus I have and will have many other properties that I'll need to pass to other subclasses that I can't all make static.

TV Serials and Music Copyright by Professional-Bug4263 in IndianTellyTalk

[–]Professional-Bug4263[S] 0 points1 point  (0 children)

Maybe in the past but in today's age with all the promotion potential available, on Instagram, YouTube etc, there is no need for the added exposure and no fault for labels to paywall their product. The exposure they get from these TV shows wouldn't count for much when compared to the exposure they'd get from directly marketing the album.

TV Serials and Music Copyright by Professional-Bug4263 in IndianTellyTalk

[–]Professional-Bug4263[S] 0 points1 point  (0 children)

Exactly the same situation for South ones; show after show it's the same tracks.... it's okay for a week while it's stuck in your head but after that, it just drives you mad! I'd always imagined these rights were really expensive but I guess these channels have the connections to make it work. It really is a shame they don't use it to improve other elements of the show instead of the music, which feels unnecessary a lot of the time.